package Lab3.Counter;

public class Counter {
    Counter() {
        this.count = 2;
        this.max = 10;
    }

    // region count and max getter&setter
    public int getCount() {
        return count;
    }

    public void setCount(int n) {
        this.count = n;
    }

    public int getMax() {
        return max;
    }

    public void setMax(int n) {
        this.max = n;
    }

    // endregion
    private int count, max;

    public void increase() {
        this.count = this.count < this.max ? this.count + 2 : 0;
    }

    public void increase(int n) {
        this.count = this.count < this.max ? this.count + n : 0;
    }

    public void decrease() {
        this.count = this.count <= 0 ? 0 : this.count--;
    }

    public void decrease(int n) {
        this.count = this.count <= 0 ? 0 : this.count - n;
    }

    public void doubler() {
        this.count *= 2;
    }

    public void reset() {
        this.count = 0;
        System.out.println("Counter Reset!");
    }

    @Override
    public String toString() {
        return "Counter{" +
                "count=" + count +
                ", max=" + max +
                '}';
    }


}
